#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
//http://oj33.cn/contest.php?cid=1075
//https://blog.csdn.net/qq_37482202/article/details/89513877
long long paiarray[100000];
int main()
{
	int long long sum = 0;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> paiarray[i];
		sum += paiarray[i];
	}
	int array = sum / n;
	for (int i = 0; i < n; i++)
	{
		paiarray[i] -= array;
	}
	int ans = 0;
	for (int i = 0; i < n-1; i++)
	{
		if (paiarray[i] == 0)continue;
			ans++;
			paiarray[i + 1] += paiarray[i];
	}
	cout << ans ;
	return 0;
}